// 客户端服务器通信测试
#include "message.hpp"
#include "net.hpp"

void omMessage(const rcrpc::BaseConnection::ptr& conn,rcrpc::BaseMessage::ptr& msg)
{
    std::string body = msg->serialize();
    std::cout << "recv msg: " << body << std::endl;
    auto rpc_rep = rcrpc::MessageFactory::create<rcrpc::RpcResponse>();
    rpc_rep->setId("11111");
    rpc_rep->setMtype(rcrpc::MType::RSP_RPC);
    rpc_rep->setRCode(rcrpc::RCode::RECODE_OK);
    rpc_rep->setResult("33");
    conn->send(rpc_rep);
}

int main()
{
    auto server = rcrpc::ServerFactory::create(9090);
    server->setMessageCallback(omMessage);
    server->start();
    return 0; 
}